<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<%=request.getContextPath()%>/common/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/common/calender.js" ></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/FSS.js" ></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/jquery-1.3.min.js"></script>

<script type="text/javascript">
function fnChangePwd(){
	if(checkInput()){
		document.changePwd.submit();
	}
}

function fnDelete(id){
	if(confirm("このユーザを削除しますか？")) {
		var strUrl = "<s:url action="delContact" namespace="/user"></s:url>";
		$.post(strUrl, {'contactId':id}, function(objRet){
			if(objRet.status == "success") {
				document.myInfo.submit();
			} else {
				alert("削除失敗！\r\n\r\nエラー：" + objRet.message);
			}
		},"json");
	}
	
}

function fnShowHide(){
	var field= document.getElementById("f_Pwd").style["visibility"];
	if(field=="hidden"){
		document.getElementById("f_Pwd").style["visibility"]="visible";
		}else{
			document.getElementById("f_Pwd").style["visibility"]="hidden";
	}
}

function fnError(){
	var error='<%=session.getAttribute("error")%>';
	if(error==null||error==""||error=="null"){
		return
	}else{
		document.getElementById("f_Pwd").style["visibility"]="visible";
	}
}

function checkInput(){
	var isNumber =/^[0-9]\d*$/;
	var isAlphabet=/^[a-zA-Z]\D*$/;
	var pwd=$("#pwd").val();
	var pwdAgain=$("#pwdAgain").val();
	
	if(LTrim(pwd).length==0)
	{
		alert("パスワードを入力してください!");
		$("#pwd").focus();
		return false;
	}	
	
	if(LTrim(pwdAgain).length == 0)
	{
		alert("パスワード再入力を入力してください!");
		$("#pwdAgain").focus();
		return false;
	}
	
	if(pwd.length < 7){
		alert("パスワードの長さは７より大きくしてください！");
		$("#pwd").focus();
		return false;
	}
	
	if(isNumber.test(pwd)||isAlphabet.test(pwd)){
		alert("パスワードの構成は数字とアルファベットが必須です！");
		$("#pwd").focus();
		return false;
	}
	
	if(pwdAgain.length!=pwd.length||pwd!=pwdAgain){
		alert("パスワードの二回の入力が違います！");
		$("#pwdAgain").focus();
		return false;
	}
	return true;
}
</script>
</head>
<body id="page5" onload="fnError();">
<div class="tail-right"></div>
<div class="tail-right-top"></div>
<div class="tail-top">
  <div class="tail-bottom">
    <div class="tail-bg">
      <div class="top-bg">
        <div class="tail-right-bot"></div>
        <div class="bot-bg">
          <div id="main">
            <!-- header -->
            <s:form name="login" action="/fssProject/Login" theme="simple">
            <div id="header">
              <h1><a href="<%=request.getContextPath()%>">fss</a></h1>
              <ul class="top-login">
              <s:if test="#session.user_login==null">
                <li><img alt="" src="<%=request.getContextPath()%>/images/userid.gif" /></li>
                <li><input type="text" name="user.userId" id="user_name" /></li>
                <li><img alt="" src="<%=request.getContextPath()%>/images/password.gif" /></li>
                <li><input type="password" name="user.pwd" id="password" /></li>
                <li><a class="loginbutton" href="javascript:fnLogin();"></a></li>
                <li><a class="registerbutton" href="<%=request.getContextPath()%>/user/initRegister" ></a></li>
              </s:if><s:else>
              	<li><h4><s:property value="#session.user_login.displayName"/>,Welcome!</h4></li>
              	<li><a class="mypagebutton" href="<%=request.getContextPath()%>/user/myInfo"></a></li>
                <li><a class="logoutbutton" href="Logout"></a></li>
                </s:else>
              </ul>
            </div>
            </s:form>
            <div class="extra-img"><img alt="" src="../images/extra-img.png" class="png"/></div>
            <div class="wrapper">
              <!-- nav -->
              <div id="nav">
                <ul>
                 <li><a href="/fssProject/mainPage">ホーム</a></li>
                  <li><a href="/fssProject/experience/list"><s:property value="#session.btn1.content"/></a></li>
                  <li><a href="/fssProject/secondHand/list"><s:property value="#session.btn2.content"/></a></li>
                  <s:if test="#session.user_login.userId in {'fss_admin1','fss_admin2','fss_admin3'}">
                  <li><a href="/fssProject/user/userManage">ユーザ管理</a></li>
                  <li><a href="/fssProject/cmsContent/editCMSContent">CMS変更</a></li>
                  </s:if>
                </ul>
              </div>
              <!-- content -->
              <div id="content">
                <div class="section">
                  <!-- box begin -->
                  <div class="box">
                    <div class="left-top-corner png">
                      <div class="right-top-corner png">
                        <div class="border-top png"></div>
                      </div>
                    </div>
                    <div class="border-left png">
                      <div class="border-right png">
                        <div class="inside png">
                          
                          <form id="contacts-form" action="#">
                            <fieldset>
                              
                              <div class="field">
                                <label>ニックネーム:</label>
                                <s:property value="#session.user_login.displayName"/>
                              </div>
                              <div class="field">
                                	<label>性別:</label>
                                	<s:if test="#session.user_login.sex==1">
                                		<span>男</span>
                                	</s:if><s:elseif test="#session.user_login.sex==2">
                                		<span>女</span>
                                	</s:elseif><s:else></s:else>
                              </div>
                              <div class="field">
                                <label>生年月日:</label>
                                <s:property value="#session.user_login.birthday"/>
                              </div>
                              <div class="field">
                                <label>国籍:</label>
                                <s:property value="#session.user_login.nationality"/>
                              </div>
                              <div class="field">
                                <label>Eメール:</label>
                                <s:property value="#session.user_login.email"/>
                              </div>
                              <div class="field">
                                <label>所属:</label>
                                <s:property value="#session.user_login.workingPlace"/>
                              </div>
                             
                              </fieldset>
                          </form>
                              <div class="commit">
                              <form id="contact-form" action="#">
                              
                            		<div style="overflow:auto">
                            		<ul class="articles">
                         			<%int i=1; %>
                            	<s:iterator id="contact" status="or" value="contactList">
                           		 	<div class="block">
                              		<h4> <%=i++ %>&nbsp;<s:property value="#contact.displayName"/>&nbsp;<s:property value="#contact.email"/> <a class="deletebutton" href="javascript:fnDelete('<s:property value='#contact.userId'/>');"></a></h4>
                              		</div>
                              </s:iterator>
                          </ul>
                            		
                            		</div>
                              </form>
                              </div>
                              
                              <div class="field">
                                <a class="pageedi" href="initEdit"></a>
                                <a class="pwdchange" href="javascript:fnShowHide();"></a>
                          	  </div>
                          <!----変更div--->
                          <form name="changePwd" id="contacts-form" method="post" action="changePwd">
                          
                            <fieldset id="f_Pwd" style="visibility: hidden;">
                            <div id="message"><h4><font color="red"><s:property value="msg"/></font></h4></div>
                         		<div id="d_oldPwd" class="field">
                                <label>旧パスワード:</label>
                                <s:password name="oldPSW"/>
                                
                              </div>
                              <div id="d_newPwd" class="field">
                                <label>新パスワード:</label>
                                <s:password id="pwd" name="newPSW"/>
                                
                              </div>
                              <div id="d_pwdAgain" class="field">
                                <label>パスワード再入力:</label>
                                <s:password id="pwdAgain" name="newPSWAgain"/>
                              </div>
                              <div id="d_btnSubmit" class="wrapper">
                          		<a class="hennkou" href="javascript:fnChangePwd();"></a>
                         	  </div>
                              </fieldset>
                          </form>
                          
                        </div>
                      </div>
                    </div>
                    <div class="left-bot-corner png">
                      <div class="right-bot-corner png">
                        <div class="border-bot png"></div>
                      </div>
                    </div>
                  </div>
                  <!-- box end -->
                </div>
              </div>
            </div>
          </div>
          <!-- footer -->
          <div id="footer">
            <div class="indent">
              <div class="fleft">Copyrights - Ritsumeikan University</div>
              <div class="fright">Designed by: <a href="http://www.ritsumei.jp/ise/index_j.html"><img src="../images/designer.gif" /> </a>Provider</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<s:form id="myInfo" action="myInfo" theme="simple">
</s:form>
</body>
</html>